﻿using System;
using System.Collections.Generic;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;

namespace AppSerwis.Model
{
    public class User
    {
        public User()
        {
            IsActive = true;
            UserID = -1;
        }

        private int _userID;
        public int UserID
        {
            get { return this._userID; }
            set { this._userID = value; }
        }

        private string _loginName;
        public string LoginName
        {
            get { return this._loginName; }
            set { this._loginName = value; }
        }

        private string _firstName;
        public string FirstName
        {
            get { return this._firstName; }
            set { this._firstName = value; }
        }

        private string _lastName;
        public string LastName 
        {
            get { return this._lastName; }
            set { this._lastName = value; }
        }

        private string _emailAdress;
        public string EmailAdress
        {
            get { return this._emailAdress; }
            set { this._emailAdress = value; }
        }

        private string _phoneNumber;
        public string PhoneNumber
        {
            get { return this._phoneNumber; }
            set { this._phoneNumber = value; }
        }

        private string _password;
        public string Password
        {
            get { return this._password; }
            set { this._password = value; }
        }

        private bool _isActive;
        public bool IsActive
        {
            get { return this._isActive; }
            set { this._isActive = value; }
        }
    }

    public class UserMapping : EntityTypeConfiguration<User>
    {
        public UserMapping()
            : base()
        { 
            this.HasKey(e =>e.UserID).Property(e =>e.UserID).HasColumnName("UserID");
            this.Property(e => e.LoginName).HasColumnName("LoginName").IsRequired();
            this.Property(e => e.FirstName).HasColumnName("FirstName").IsRequired();
            this.Property(e => e.LastName).HasColumnName("LastName").IsRequired();
            this.Property(e => e.PhoneNumber).HasColumnName("PhoneNumber").IsRequired();
            this.Property(e => e.EmailAdress).HasColumnName("EmailAdress").IsRequired();
            this.Property(e => e.Password).HasColumnName("Password").IsRequired();
            this.Property(e => e.IsActive).HasColumnName("IsActive");
        }
    }
}
